'app-filter-changed': {},
'session-limits-changed': {},
},
+ Properties: {
+ 'any-parental-controls-enabled': GObject.ParamSpec.boolean(
+ 'any-parental-controls-enabled', null, null,
+ GObject.ParamFlags.READABLE,
+ false),
+ },
}, class ParentalControlsManager extends GObject.Object {
_init() {
super._init();
this._initialized = true;
this.emit('app-filter-changed');
this.emit('session-limits-changed');
+ this.notify('any-parental-controls-enabled');
return;
}
this._initialized = true;
this.emit('app-filter-changed');
this.emit('session-limits-changed');
+ this.notify('any-parental-controls-enabled');
}
async _getAppFilter() {
try {
this._appFilter = await this._getAppFilter();
this.emit('app-filter-changed');
+ this.notify('any-parental-controls-enabled');
} catch (e) {
// Log an error and keep the old app filter.
logError(e, `Failed to get new MctAppFilter for uid ${Shell.util_get_uid()} on app-filter-changed`);
try {
this._sessionLimits = await this._getSessionLimits();
this.emit('session-limits-changed');
+ this.notify('any-parental-controls-enabled');
} catch (e) {
// Keep the old session limits
logError(e, `Failed to get new MctSessionLimits for uid ${Shell.util_get_uid()} on session-limits-changed`);
return this._appFilter.is_appinfo_allowed(appInfo);
}
+ /**
+ * Check whether parental controls app filtering is enabled for the account,
+ * and if the library supports the features required for the functionality.
+ *
+ * Typically you should check whether a certain app is filtered
+ * (shouldShowApp()), rather than checking whether filtering is enabled at
+ * all.
+ *
+ * @returns {bool} whether app filtering is supported and enabled.
+ */
+ appFilterEnabled() {
+ // Are latest parental controls enabled (at configure or runtime)?
+ if (!HAVE_MALCONTENT_0_14 || this._disabled)
+ return false;
+
+ // Have we finished initialising yet?
+ if (!this.initialized) {
+ console.debug('Ignoring app filter because parental controls not yet initialised');
+ return false;
+ }
+
+ return this._appFilter.is_enabled();
+ }
+
/**
* Check whether parental controls session limits are enabled for the account,
* and if the library supports the features required for the functionality.
return this._sessionLimits.is_enabled();
}
+
+ /**
+ * Whether any parental controls are supported and enabled for the current
+ * user.
+ *
+ * @type {bool}
+ */
+ get anyParentalControlsEnabled() {
+ return this.appFilterEnabled() || this.sessionLimitsEnabled();
+ }
});